
import com.james.entity.User;
import com.james.repository.UserRepository;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;


import java.io.InputStream;
import java.util.List;


public class MyBatisTest {
    @Test
    public void Test1(){
        InputStream inputStream = MyBatisTest.class.getClassLoader().getResourceAsStream("config.xml");
        SqlSessionFactoryBuilder sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
        SqlSessionFactory sqlSessionFactory = sqlSessionFactoryBuilder.build(inputStream);
        SqlSession sqlSession = sqlSessionFactory.openSession();
        //String statement = "com.james.repository.UserRepository.findAll";
        UserRepository userRepository = sqlSession.getMapper(UserRepository.class);
        List<User> list = userRepository.findAll();
        sqlSession.commit();
        sqlSession.close();
        System.out.println(list);
    }
}
